package com.paqCliente;

import com.paqCliente.R;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.EditText;

public class poner_password_cliente extends DialogFragment implements
		OnItemSelectedListener {

	public poner_password_cliente() {
		super();
	}

	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		final AlertDialog.Builder builder = new AlertDialog.Builder(
				getActivity());
		LayoutInflater inflater = getActivity().getLayoutInflater();
		View rootView = inflater.inflate(R.layout.dialog_signin, null);

//		final EditText tservidor = (EditText) rootView.findViewById(R.id.username);
//		if (servidor_cliente.nombre != null)
//			tservidor.setText(servidor_cliente.nombre);
//		else
//			tservidor.setText(cliente.nombre_servidor);
//		
//
//		final EditText tpass = (EditText) rootView.findViewById(R.id.password);
//		if (servidor_cliente.password != null)
//			tpass.setText(servidor_cliente.password);
//		else
//			tpass.setText(cliente.pass_servidor);

		// ---------------------------------------------------------------------------------------------------------------------------------------------

		builder.setView(rootView);
		// Add action buttons
		builder.setPositiveButton(R.string.aceptar,
				new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int id) {
						
				//		servidor_cliente.nombre=tservidor.getText().toString();
				//		servidor_cliente.password=tpass.getText().toString();
//						paquete mipaquete = new paquete(false, 11, null, null,0, null, null, null);
						dialog.dismiss();
						sock_cliente comunicacion = new sock_cliente ();
						comunicacion.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
					}
				});
		builder.setNegativeButton(R.string.cancelar,
				new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int id) {
						dialog.cancel();
						System.exit(0);
					}
				});
		AlertDialog b = builder.create();
		b.show();

		return b;

	}

	public void onItemSelected(AdapterView<?> parent, View view, int pos,
			long id) {
		// An item was selected. You can retrieve the selected item using
		/*
		 * Spinner spinner = (Spinner) parent; if(spinner.getId() ==
		 * R.id.spinnerDato1){
		 * 
		 * }
		 */
	}

	public void onNothingSelected(AdapterView<?> parent) {
		// Another interface callback
	}

	public void onDismiss(DialogInterface dialog) {

	}

}
